package com.mobisys.live.util;

import java.util.ArrayList;
import java.util.List;

public class IdStrUtil {

    /**
     * 通过id串获得id列表，用于后续的查询
     * id之间通过逗号来分隔
     * @param idStr
     * @return
     */
    public static List<Integer> convertToIdList(String idStr){
        String[] ids=idStr.split(",");
        List<Integer> idList=new ArrayList<>();
        for (int i = 0; i < ids.length; i++) {
            int id=Integer.parseInt(ids[i]);
            idList.add(id);
        }
        return idList;

    }


    /**
     * 将id列表拼成id串
     * @param idList
     * @return
     */
    public static String convertToIdStr(List<Integer> idList){
        StringBuilder stringBuilder=new StringBuilder();
        for (int i = 0; i < idList.size(); i++) {
            stringBuilder.append(idList.get(i));
        }
        return stringBuilder.toString();
    }
}
